
<!DOCTYPE html>
<html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <meta name="author" content="Alexander Barth">

   <title>matplot: pcolor on non-rectangular grid</title>
   <link href="style.css" rel="stylesheet" type="text/css" />
   <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />
   <script type="text/javascript" src="prettify/prettify.js"></script>
   <script type="text/javascript" src="numeric-1.2.3.js"></script>
   <link href="../matplot.css" rel="stylesheet" type="text/css" />
   <script type="text/javascript" src="matplot.js"></script>


   <script type="text/javascript">
function init() {      
  
var i,j,x=[],y=[],z=[], r, theta;

// generate some data to plot
for (i=0; i < 100; i++) {
  x[i] = [];
  y[i] = [];
  z[i] = [];

  for (j=0; j < 100; j++) {
    r = 20 + i;
    theta = 2*Math.PI * j/99;
    x[i][j] = r*Math.cos(theta);
    y[i][j] = r*Math.sin(theta);
    z[i][j] = Math.cos(2*theta);
  }
}

fig = new matplot.Figure("plot",700,500);
ax = fig.axes();
ax.pcolor(x,y,z);
ax.colorbar();
ax.DataAspectRatio([1,1,1]);
fig.draw();


}

addEventListener('load', function (event) { prettyPrint() }, false);

    </script>
 </head>
    <body onload="init()">
    <h1>matplot: pcolor on non-rectangular grid</h1>
    <p>2D pseudo color plot on non-rectangular grid (function pcolor)</p>
    <div id="plot"></div>
    <h2>Code:</h2>
    <pre class=prettyprint>

var i,j,x=[],y=[],z=[], r, theta;

// generate some data to plot
for (i=0; i &lt; 100; i++) {
  x[i] = [];
  y[i] = [];
  z[i] = [];

  for (j=0; j &lt; 100; j++) {
    r = 20 + i;
    theta = 2*Math.PI * j/99;
    x[i][j] = r*Math.cos(theta);
    y[i][j] = r*Math.sin(theta);
    z[i][j] = Math.cos(2*theta);
  }
}

fig = new matplot.Figure("plot",700,500);
ax = fig.axes();
ax.pcolor(x,y,z);
ax.colorbar();
ax.DataAspectRatio([1,1,1]);
fig.draw();


    </pre>    
  </body>
</html>
